'use strict';

/** @type {import('sequelize-cli').Migration} */
const { v4: uuidv4 } = require('uuid');
module.exports = {
  async up(queryInterface, Sequelize) {
    try {
      await queryInterface.bulkInsert('Orders', [
        {
          outTradeNo: uuidv4().replace(/-/g, ''),
          userId: 2,
          subject: '月付',
          totalAmount: 10,
          paymentMethod: 0,
          status: 2,
          paidAt: null,
          membershipMonths: 1,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          outTradeNo: uuidv4().replace(/-/g, ''),
          userId: 2,
          subject: '年付',
          totalAmount: 100,
          paymentMethod: 1,
          membershipMonths: 12,
          status: 0,
          paidAt: null,
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          outTradeNo: uuidv4().replace(/-/g, ''),
          userId: 5,
          subject: '年付',
          totalAmount: 100,
          membershipMonths: 12,
          paymentMethod: 1,
          status: 1,
          paidAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
      ]);
    } catch (error) {
      console.error('详细错误信息：', error); // 打印完整错误
    }
  },

  async down(queryInterface, Sequelize) {
    /**
     * Add commands to revert seed here.
     *
     * Example:
     * await queryInterface.bulkDelete('People', null, {});
     */
    await queryInterface.bulkDelete('Orders', null, {});
  },
};
